package com.xm.settlement.controller;

import com.xm.settlement.commons.base.BaseController;
import com.xm.settlement.commons.utils.PageInfo;
import com.xm.settlement.model.ConsumptionUpload;
import com.xm.settlement.service.ConsumptionUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/4/24.
 */
@RequestMapping("/consumeVerify")
@Controller
public class ConsumeVerifyController extends BaseController  {

    @Autowired
    private ConsumptionUploadService consumptionUploadService;

    /**
     * 权限管理页
     *
     * @return
     */
    @GetMapping("/manager")
    public String manager() {
        return "settlement/consumeVerify/consumeVerify";
    }

    /**
     * 权限列表
     * @param page
     * @param rows
     * @param sort
     * @param order
     * @return
     */
    @PostMapping("/dataGrid")
    @ResponseBody
    public Object dataGrid(Integer page, Integer rows, String sort, String order) {
        PageInfo pageInfo = new PageInfo(page, rows, sort, order);
        Map<String, Object> condition = new HashMap<String, Object>();
        pageInfo.setCondition(condition);
        consumptionUploadService.selectDataGrid(pageInfo);
        return pageInfo;
    }

    /**
     * 审核通过
     *
     * @param id
     * @return
     */
    @RequestMapping("/passVerify")
    @ResponseBody
    public Object passVerify(Long id,Integer type) {
        return (consumptionUploadService.passVerify(id,type) == 1) ? renderSuccess("审核通过") : renderError("审核未通过！");
    }
}
